<template>
  <div>
      <!-- 顶部导航栏 -->
    <van-nav-bar
      title="不凡"
      left-text="返回"
      left-arrow
      @click-left="onClickLeft"
    />

    <!-- 地址栏 -->
<van-address-list
  v-model="chosenAddressId"
  :list="list"
  default-tag-text="默认"
  @add="onAdd"
  @edit="onEdit"
/>






  </div>
</template>


<script>
import {getListAction} from '@/api/mine/address';
export default {
  data() {
      return{
        chosenAddressId: '',
        list:[],
   
      }
  },
  created(){
      var user= localStorage.getItem("openId")
      console.log(user);
      getListAction({
          openId:user
      }).then(res=>{
        this.list=res.data
        res.data.forEach(e => {
            e.tel = e.mobile
        });
          console.log(res.data);
      })
  },
  methods: {
    onClickLeft() {
      this.$router.push("/mine")
    },
     onAdd() {
    //   Toast('新增地址');
        this.$router.push("/mine/address/newAddress")
    },
    onEdit(item, index) {
    //   Toast('编辑地址:' + index);
    
    // 将地址发送给编辑地址页面
    this.$router.push({path:'/mine/address/editAddress',query:{
     item:JSON.stringify(item)
    }})
    
    },
  },
};
</script>




<style lang="scss">
.van-nav-bar__left .van-nav-bar__text,
.van-nav-bar__left .van-icon-arrow-left{
    color: #b4282d;
}

</style>


<style lang="scss" scoped>

</style>